package c.c.a;

import android.content.Context;

public class w1 extends q1 {
    public static final long[] f = new long[]{60000, 60000, 60000, 120000, 120000, 120000, 180000, 180000};
    public static final long[] g = new long[]{180000, 180000, 360000, 360000, 540000, 540000};
    public static final long[] h = new long[]{10000, 10000, 20000, 20000, 60000, 6000, 180000, 180000, 540000, 540000};
    public c d;
    public y1 e;

    public w1(Context context, c cVar, y1 y1Var) {
        super(context);
        this.d = cVar;
        this.e = y1Var;
    }

    public boolean a() {
        return true;
    }

    public long b() {
        long optLong = this.d.d.optLong("register_time", 0);
        y1 y1Var = this.e;
        Object obj = (y1Var.i && y1Var.j == 0) ? 1 : null;
        return optLong + ((long) (obj != null ? 21600000 : 43200000));
    }

    public long[] c() {
        long[] jArr = g;
        int j = this.d.j();
        if (j == 0) {
            return h;
        }
        if (j == 1) {
            return jArr;
        }
        if (j == 2) {
            return f;
        }
        m0.b(null);
        return jArr;
    }

    /* JADX WARNING: Removed duplicated region for block: B:14:0x0074  */
    public boolean d() {
        /*
        r17 = this;
        r1 = r17;
        r0 = new org.json.JSONObject;
        r0.<init>();
        r2 = r1.d;
        r2 = r2.a();
        r3 = 0;
        if (r2 == 0) goto L_0x0161;
    L_0x0010:
        r5 = "magic_tag";
        r6 = "ss_app_log";
        r0.put(r5, r6);
        r5 = "header";
        r0.put(r5, r2);
        r5 = java.lang.System.currentTimeMillis();
        r2 = "_gen_time";
        r0.put(r2, r5);
        r2 = r1.a;
        r5 = r1.d;
        r5 = r5.a();
        r6 = c.c.a.q.f;
        r6 = r6.getRegisterUri();
        r7 = com.bytedance.embedapplog.AppLog.getIAppParam();
        r8 = 1;
        r2 = c.c.a.r.a(r2, r5, r6, r8, r7);
        r5 = new java.util.HashMap;
        r6 = 2;
        r5.<init>(r6);
        r6 = com.bytedance.embedapplog.AppLog.getEncryptAndCompress();
        r7 = "Content-Type";
        if (r6 == 0) goto L_0x0050;
    L_0x004a:
        r6 = "application/octet-stream;tt-data=a";
        r5.put(r7, r6);
        goto L_0x0055;
    L_0x0050:
        r6 = "application/json; charset=utf-8";
        r5.put(r7, r6);
    L_0x0055:
        r2 = c.c.a.q.b(r2);
        r0 = r0.toString();
        r0 = com.bytedance.embedapplog.AppLog.toEncryptByte(r0);
        r0 = c.c.a.q.a(r8, r2, r5, r0);
        if (r0 == 0) goto L_0x0071;
    L_0x0067:
        r2 = new org.json.JSONObject;	 Catch:{ JSONException -> 0x006d }
        r2.<init>(r0);	 Catch:{ JSONException -> 0x006d }
        goto L_0x0072;
    L_0x006d:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x0071:
        r2 = r3;
    L_0x0072:
        if (r2 == 0) goto L_0x0164;
    L_0x0074:
        r0 = "device_id";
        r5 = "";
        r12 = r2.optString(r0, r5);
        r6 = "install_id";
        r14 = r2.optString(r6, r5);
        r7 = "ssid";
        r15 = r2.optString(r7, r5);
        r9 = r1.d;
        java.util.Objects.requireNonNull(r9);
        r10 = "register_time";
        r11 = "version_code";
        r13 = c.c.a.m0.b;
        if (r13 == 0) goto L_0x00bd;
    L_0x0095:
        r13 = new java.lang.StringBuilder;
        r13.<init>();
        r8 = "saveRegisterInfo, ";
        r13.append(r8);
        r13.append(r12);
        r8 = ", ";
        r13.append(r8);
        r13.append(r14);
        r13.append(r8);
        r13.append(r15);
        r13.append(r8);
        r13.append(r2);
        r8 = r13.toString();
        c.c.a.m0.a(r8, r3);
    L_0x00bd:
        r3 = c.c.a.c.i(r12);
        r8 = c.c.a.c.i(r14);
        r13 = c.c.a.c.i(r15);	 Catch:{ JSONException -> 0x0155 }
        r4 = r9.f;	 Catch:{ JSONException -> 0x0155 }
        r1 = 0;
        r4 = r4.getInt(r11, r1);	 Catch:{ JSONException -> 0x0155 }
        r1 = r9.d;	 Catch:{ JSONException -> 0x0155 }
        r16 = r15;
        r15 = 0;
        r1 = r1.optInt(r11, r15);	 Catch:{ JSONException -> 0x0155 }
        r15 = r9.f;	 Catch:{ JSONException -> 0x0155 }
        r15 = r15.edit();	 Catch:{ JSONException -> 0x0155 }
        if (r4 == r1) goto L_0x00e4;
    L_0x00e1:
        r15.putInt(r11, r1);	 Catch:{ JSONException -> 0x0155 }
    L_0x00e4:
        if (r3 == 0) goto L_0x00f5;
    L_0x00e6:
        r1 = java.lang.System.currentTimeMillis();	 Catch:{ JSONException -> 0x0155 }
        r15.putLong(r10, r1);	 Catch:{ JSONException -> 0x0155 }
        r1 = java.lang.Long.valueOf(r1);	 Catch:{ JSONException -> 0x0155 }
        r9.d(r10, r1);	 Catch:{ JSONException -> 0x0155 }
        goto L_0x0106;
    L_0x00f5:
        if (r3 != 0) goto L_0x0106;
    L_0x00f7:
        r1 = new org.json.JSONObject;	 Catch:{ JSONException -> 0x0155 }
        r1.<init>();	 Catch:{ JSONException -> 0x0155 }
        r4 = "response";
        r1.put(r4, r2);	 Catch:{ JSONException -> 0x0155 }
        r2 = "tt_fetch_did_error";
        com.bytedance.embedapplog.AppLog.onEventV3(r2, r1);	 Catch:{ JSONException -> 0x0155 }
    L_0x0106:
        r1 = r9.d;	 Catch:{ JSONException -> 0x0155 }
        r11 = r1.optString(r0, r5);	 Catch:{ JSONException -> 0x0155 }
        if (r3 == 0) goto L_0x0119;
    L_0x010e:
        r1 = r9.d(r0, r12);	 Catch:{ JSONException -> 0x0155 }
        if (r1 == 0) goto L_0x0119;
    L_0x0114:
        r15.putString(r0, r12);	 Catch:{ JSONException -> 0x0155 }
        r1 = 1;
        goto L_0x011a;
    L_0x0119:
        r1 = 0;
    L_0x011a:
        r0 = r9.d;	 Catch:{ JSONException -> 0x0155 }
        r0 = r0.optString(r6, r5);	 Catch:{ JSONException -> 0x0155 }
        if (r8 == 0) goto L_0x012c;
    L_0x0122:
        r2 = r9.d(r6, r14);	 Catch:{ JSONException -> 0x0155 }
        if (r2 == 0) goto L_0x012c;
    L_0x0128:
        r15.putString(r6, r14);	 Catch:{ JSONException -> 0x0155 }
        r1 = 1;
    L_0x012c:
        r2 = r9.d;	 Catch:{ JSONException -> 0x0155 }
        r2 = r2.optString(r7, r5);	 Catch:{ JSONException -> 0x0155 }
        if (r13 == 0) goto L_0x0141;
    L_0x0134:
        r4 = r16;
        r5 = r9.d(r7, r4);	 Catch:{ JSONException -> 0x0155 }
        if (r5 == 0) goto L_0x0143;
    L_0x013c:
        r15.putString(r7, r4);	 Catch:{ JSONException -> 0x0155 }
        r10 = 1;
        goto L_0x0144;
    L_0x0141:
        r4 = r16;
    L_0x0143:
        r10 = r1;
    L_0x0144:
        r9 = com.bytedance.embedapplog.AppLog.getDataObserver();	 Catch:{ JSONException -> 0x0155 }
        r13 = r0;
        r0 = r4;
        r1 = r15;
        r15 = r2;
        r16 = r0;
        r9.onRemoteIdGet(r10, r11, r12, r13, r14, r15, r16);	 Catch:{ JSONException -> 0x0155 }
        r1.apply();	 Catch:{ JSONException -> 0x0155 }
        goto L_0x0159;
    L_0x0155:
        r0 = move-exception;
        c.c.a.m0.b(r0);
    L_0x0159:
        if (r3 == 0) goto L_0x015f;
    L_0x015b:
        if (r8 == 0) goto L_0x015f;
    L_0x015d:
        r4 = 1;
        goto L_0x0160;
    L_0x015f:
        r4 = 0;
    L_0x0160:
        return r4;
    L_0x0161:
        c.c.a.m0.b(r3);
    L_0x0164:
        r1 = 0;
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.a.w1.d():boolean");
    }

    public String e() {
        return "r";
    }
}
